﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class administrator_Contact : System.Web.UI.Page
{
    dulieuDataContext db = new dulieuDataContext();
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack)
        {
            LoadMenu();
        }
    }
  
    protected void LoadMenu()
    {
        rptmnu.DataSource = from o in db.UserContacts select o;
        rptmnu.DataBind();
    }

    protected void DeleteMenu(object s, ImageClickEventArgs e)
    {
        foreach (RepeaterItem item in rptmnu.Items)
        {
            var chk = (CheckBox)item.FindControl("chk");
            if (chk.Checked)
            {
                var lblid = (Label)item.FindControl("lblid");
                var us = (from o in db.UserContacts where o.id == Convert.ToInt32(lblid.Text) select o).SingleOrDefault();
                if (us != null) db.UserContacts.DeleteOnSubmit(us);
                db.SubmitChanges();
            }
        }
        System.Threading.Thread.Sleep(800);
        lblthongbao.Text = "Xóa thành công";
        LoadMenu();
    }
}